package com.wondedDream.repository;

import com.wondedDream.model.UserMockExamRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.time.LocalDateTime;
import java.util.List;

public interface UserMockExamRecordRepository extends JpaRepository<UserMockExamRecord, Integer> {
    // 这里假设主键是 String 类型，如果是 Long 或其他类型，请相应修改
    @Query("SELECT u FROM UserMockExamRecord u WHERE u.submitTime BETWEEN :startTime AND :endTime")
    List<UserMockExamRecord> findBySubmitTimeBetween(LocalDateTime startTime, LocalDateTime endTime);
    // 这里假设主键是 String 类型，如果是 Long 或其他类型，请相应修改
    List<UserMockExamRecord> findByUserId(Integer userId);
    List<UserMockExamRecord> findByMockExamId(Integer mockExamId);

    @Query("SELECT u FROM UserMockExamRecord u WHERE u.user.openid = :userOpenId AND u.mockExam.id = :mockExamId")
    UserMockExamRecord findByUserIdAndMockExamId(String userOpenId, Integer mockExamId);

    @Query("SELECT u FROM UserMockExamRecord u WHERE u.user.openid = :userOpenId AND u.mockExam.id IN :mockExamIdList ")
    List<UserMockExamRecord> findByUserOpenIdAndMockExamId(String userOpenId, List<Integer> mockExamIdList);
}